Problem: Regular octagon $A_1A_2A_3A_4A_5A_6A_7A_8$ is inscribed in a circle of area $1.$ Point $P$ lies inside the circle so that the region bounded by $\overline{PA_1},\overline{PA_2},$ and the minor arc $\widehat{A_1A_2}$ of the circle has area $\tfrac{1}{7},$ while the region bounded by $\overline{PA_3},\overline{PA_4},$ and the minor arc $\widehat{A_3A_4}$ of the circle has area $\tfrac{1}{9}.$ There is a positive integer $n$ such that the area of the region bounded by $\overline{PA_6},\overline{PA_7},$ and the minor arc $\widehat{A_6A_7}$ of the circle is equal to $\tfrac{1}{8}-\tfrac{\sqrt2}{n}.$ Find $n.$

The actual size of the diagram doesn't matter. To make calculation easier, we discard the original area of the circle, $1$, and assume the side length of the octagon is $2$. Let $r$ denote the radius of the circle, $O$ be the center of the circle. Then $r^2= 1^2 + (\sqrt{2}+1)^2= 4+2\sqrt{2}$. Now, we need to find the "D"shape, the small area enclosed by one side of the octagon and 1/8 of the circumference of the circle:\[D= \frac{1}{8} \pi r^2 - [A_1 A_2 O]=\frac{1}{8} \pi (4+2\sqrt{2})- (\sqrt{2}+1)\]
Let $PU$ be the height of $\triangle A_1 A_2 P$, $PV$ be the height of $\triangle A_3 A_4 P$, $PW$ be the height of $\triangle A_6 A_7 P$. From the $1/7$ and $1/9$ condition we have\[\triangle P A_1 A_2= \frac{\pi r^2}{7} - D= \frac{1}{7} \pi (4+2\sqrt{2})-(\frac{1}{8} \pi (4+2\sqrt{2})- (\sqrt{2}+1))\]
\[\triangle P A_3 A_4= \frac{\pi r^2}{9} - D= \frac{1}{9} \pi (4+2\sqrt{2})-(\frac{1}{8} \pi (4+2\sqrt{2})- (\sqrt{2}+1))\]which gives $PU= (\frac{1}{7}-\frac{1}{8}) \pi (4+ 2\sqrt{2}) + \sqrt{2}+1$ and $PV= (\frac{1}{9}-\frac{1}{8}) \pi (4+ 2\sqrt{2}) + \sqrt{2}+1$. Now, let $A_1 A_2$ intersects $A_3 A_4$ at $X$, $A_1 A_2$ intersects $A_6 A_7$ at $Y$,$A_6 A_7$ intersects $A_3 A_4$ at $Z$. Clearly, $\triangle XYZ$ is an isosceles right triangle, with right angle at $X$ and the height with regard to which shall be $3+2\sqrt2$. Now $\frac{PU}{\sqrt{2}} + \frac{PV}{\sqrt{2}} + PW = 3+2\sqrt2$ which gives $PW= 3+2\sqrt2-\frac{PU}{\sqrt{2}} - \frac{PV}{\sqrt{2}}$
$=3+2\sqrt{2}-\frac{1}{\sqrt{2}}((\frac{1}{7}-\frac{1}{8}) \pi (4+ 2\sqrt{2}) + \sqrt{2}+1+(\frac{1}{9}-\frac{1}{8}) \pi (4+ 2\sqrt{2}) + \sqrt{2}+1))$
$=1+\sqrt{2}- \frac{1}{\sqrt{2}}(\frac{1}{7}+\frac{1}{9}-\frac{1}{4})\pi(4+2\sqrt{2})$
Now, we have the area for $D$ and the area for $\triangle P A_6 A_7$, so we add them together:
$\text{Target Area} = \frac{1}{8} \pi (4+2\sqrt{2})- (\sqrt{2}+1) + (1+\sqrt{2})- \frac{1}{\sqrt{2}}(\frac{1}{7}+\frac{1}{9}-\frac{1}{4})\pi(4+2\sqrt{2})$
$=(\frac{1}{8} - \frac{1}{\sqrt{2}}(\frac{1}{7}+\frac{1}{9}-\frac{1}{4}))\text{Total Area}$
The answer should therefore be $\frac{1}{8}- \frac{\sqrt{2}}{2}(\frac{16}{63}-\frac{16}{64})=\frac{1}{8}- \frac{\sqrt{2}}{504}$. The answer is $\boxed{504}$.